package com.szrt.java.day20170103.demo12;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.junit.Test;

public class CarTest {

	@Test
	public void test() {
		
		Car car = new Car();
		car  = null;
		car.setPrice(100);
		System.out.println(car.getPrice());
	}
	
	
	@Test
	public void jdbc() {
		
		mysql();
		
		
	}
	
	//java.sql.SQLException
	public void mysql(){
		try {
			//1 加载驱动类
			Class.forName("com.mysql.jdbc.Driver");
			
			
			//2获得连接
			Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db1612", "root", "123456");
			
			System.out.println("连接成功...");
			System.out.println(connection.getClass());
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
				
	}

}
